<template>
	<view class="top">
		<view class="top">
			<u-navbar :is-back="true" title="商品详情" :border-bottom="false" :title-bold="true"></u-navbar>
		</view>
		<view class="contentView">
			<view class="headerView">
				<view class="headerTitle">用户评价</view>
				<view class="headerText">{{commentList.length}}条好评</view>
				<u-icon name="arrow-right" size="20" color="#666"></u-icon>
			</view>
			<view class="commentView" v-for="(item,index) in commentList" :key="index">
				<view class="commentUser">
					<u-avatar :src="item.user.avatar_format" size="70"></u-avatar>
					<view class="userInfo">
						<view class="username">
							<text>{{item.user.nickname}}</text>
							<span v-if="item.goods_star==1">特别差</span>
							<span v-if="item.goods_star==2">差</span>
							<span v-if="item.goods_star==3">一般</span>
							<span v-if="item.goods_star==4">好</span>
							<span v-if="item.goods_star==5">非常好</span>
						</view>
						<view class="commentTime">
							<text>2021-11-02</text>
							<u-rate :count="5" v-model="item.goods_star" disabled :size="10" active-color="#FFAC0E"></u-rate>
						</view>
					</view>
				</view>
				<view class="commentText">{{item.content}}</view>
				<view class="commentImage" v-if="item.images_format" v-for="(c,i) in item.images_format" :key="i" >
					<image class="imageIcon" :src="c" mode="aspectFill" ></image>
					
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getComment
	} from '@/api/index.js'
	export default {
		data() {
			return {
				commentList:[]
			};
		},
		onLoad(res) {
			getComment(res.id).then(res => {
				console.log("评论", res);
				this.commentList = res.list
			})
		}
	}
</script>

<style lang="scss">
	.contentView {
		display: flex;
		flex-direction: column;
		background: #FFFFFF;
		padding: 0 20rpx;
	}

	.goodsTitle {
		padding: 25rpx 0;
		font-weight: 400;
		font-size: 30rpx;
		color: #333333;
	}

	.saleCount {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.saleCount text {
		font-weight: 400;
		font-size: 28rpx;
		color: #999999;
		margin-right: 30rpx;
	}

	.goodsPrice {
		flex: 1;
		font-weight: bold;
		font-size: 32rpx;
		color: #FA453C;
	}

	.storeView {
		display: flex;
		flex-direction: row;
		align-items: center;
		background: #FFFFFF;
		padding: 25rpx 20rpx;
	}

	.storeName {
		flex: 1;
		font-weight: 400;
		font-size: 30rpx;
		color: #333333;
		margin-left: 10rpx;
	}

	.headerView {
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 20rpx 0px;
	}

	.headerTitle {
		flex: 1;
		font-weight: 400;
		font-size: 30rpx;
		color: #333333;
	}

	.headerText {
		font-weight: 400;
		font-size: 24rpx;
		color: #999999;
	}

	.commentView {
		display: flex;
		flex-direction: column;
		background: #FFFFFF;
		padding: 20rpx 0px;
	}

	.commentUser {
		display: flex;
		flex-direction: row;
	}

	.userInfo {
		flex: 1;
		display: flex;
		flex-direction: column;
		margin-left: 10rpx;
	}

	.username {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		font-weight: 400;
		font-size: 24rpx;
		color: #333333;
	}

	.commentTime {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		font-weight: 400;
		font-size: 20rpx;
		color: #999;
	}

	.commentText {
		font-weight: 400;
		font-size: 24rpx;
		color: #333333;
		margin-top: 20rpx;
	}

	.commentImage {
		display: flex;
		flex-wrap: wrap;
		margin-top: 20rpx;
	}

	.imageIcon {
		width: 216rpx;
		height: 145rpx;
		margin-right: 20rpx;
	}

	.detailsView {
		display: flex;
		flex-direction: column;
		align-items: center;
		background: #FFFFFF;
		margin-top: 20rpx;
	}

	.goodsDetail {
		font-size: 26rpx;
		font-weight: 400;
		color: #333;
		padding: 20rpx 0px;
	}

	.bottomView {
		display: flex;
		flex-direction: row;
		align-items: center;
		width: 100%;
		height: 100rpx;
		background: #FFFFFF;
		box-shadow: 0px -1px 10rpx 0px rgba(153, 153, 153, 0.1);
		position: fixed;
		bottom: 0px;
	}
</style>
